//
//  PackageDetailBannerCell.m
//  BaseProject
//
//  Created by 王洋 on 2020/8/2.
//  Copyright © 2020 王洋. All rights reserved.
//

#import "PackageDetailBannerCell.h"

@interface PackageDetailBannerCell ()<SDCycleScrollViewDelegate>

@end

@implementation PackageDetailBannerCell

+ (CGFloat)calculateHeight {
    return TTScreenWidth * 0.7;
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        self.backgroundColor = [UIColor whiteColor];
        [self layout];
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];

}

- (void)pause {
    [self.mediaBanner pause];
}

- (void)layout {
    
    [self addSubview:self.mediaBanner];
    
    [self.mediaBanner mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.bottom.mas_equalTo(0);
    }];
    
    [self layoutIfNeeded];
}

- (void)fillWithImgArray:(NSMutableArray *)imgArray AndVideoUrl:(NSString *)videoUrl {
    [self.mediaBanner fillWithImgArray:imgArray AndVideoUrl:videoUrl];
}

- (void)fillWithImgArray:(NSMutableArray *)imgArray videoUrl:(NSString *)videoUrl andMaskUrl:(NSString *)maskUrl {
    [self.mediaBanner fillWithImgArray:imgArray videoUrl:videoUrl andMaskUrl:maskUrl];
}

- (BA_MediaBannerView *)mediaBanner {
    if (!_mediaBanner) {
        _mediaBanner = [[BA_MediaBannerView alloc] init];
        
        WEAKSELF
        _mediaBanner.bannerIndexClicked = ^(NSInteger index) {
            if (weakSelf.bannerIndexClicked) {
                weakSelf.bannerIndexClicked(index);
            }
        };
    }
    return _mediaBanner;
}

@end
